﻿// Decompiled with JetBrains decompiler
// Type: System.Web.Razor.Generator.CodeWriter
// Assembly: System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// MVID: 682513D6-F37E-48AC-9909-F3EE103CFF14
// Assembly location: D:\Project\Idea\无人机外网\uav\客户端工程\排查工具\bin\Release\System.Web.Razor.dll

using System.CodeDom;
using System.Globalization;
using System.IO;

namespace System.Web.Razor.Generator
{
  internal abstract class CodeWriter : IDisposable
  {
    private StringWriter _writer;

    public string Content => this.InnerWriter.ToString();

    public StringWriter InnerWriter
    {
      get
      {
        if (this._writer == null)
          this._writer = new StringWriter((IFormatProvider) CultureInfo.InvariantCulture);
        return this._writer;
      }
    }

    public virtual bool SupportsMidStatementLinePragmas => true;

    public abstract void WriteParameterSeparator();

    public abstract void WriteReturn();

    public abstract void WriteLinePragma(int? lineNumber, string fileName);

    public abstract void WriteHelperHeaderPrefix(string templateTypeName, bool isStatic);

    public abstract void WriteSnippet(string snippet);

    public abstract void WriteStringLiteral(string literal);

    public abstract int WriteVariableDeclaration(string type, string name, string value);

    public virtual void WriteLinePragma() => this.WriteLinePragma((CodeLinePragma) null);

    public virtual void WriteLinePragma(CodeLinePragma pragma)
    {
      if (pragma == null)
        this.WriteLinePragma(new int?(), (string) null);
      else
        this.WriteLinePragma(new int?(pragma.LineNumber), pragma.FileName);
    }

    public virtual void WriteHiddenLinePragma()
    {
    }

    public virtual void WriteDisableUnusedFieldWarningPragma()
    {
    }

    public virtual void WriteRestoreUnusedFieldWarningPragma()
    {
    }

    public virtual void WriteIdentifier(string identifier) => this.InnerWriter.Write(identifier);

    public virtual void WriteHelperHeaderSuffix(string templateTypeName)
    {
    }

    public virtual void WriteHelperTrailer()
    {
    }

    public void WriteStartMethodInvoke(string methodName) => this.EmitStartMethodInvoke(methodName);

    public void WriteStartMethodInvoke(string methodName, params string[] genericArguments) => this.EmitStartMethodInvoke(methodName, genericArguments);

    public void WriteEndMethodInvoke() => this.EmitEndMethodInvoke();

    public virtual void WriteEndStatement()
    {
    }

    public virtual void WriteStartAssignment(string variableName)
    {
      this.InnerWriter.Write(variableName);
      this.InnerWriter.Write(" = ");
    }

    public void WriteStartLambdaExpression(params string[] parameterNames) => this.EmitStartLambdaExpression(parameterNames);

    public void WriteStartConstructor(string typeName) => this.EmitStartConstructor(typeName);

    public void WriteStartLambdaDelegate(params string[] parameterNames) => this.EmitStartLambdaDelegate(parameterNames);

    public void WriteEndLambdaExpression() => this.EmitEndLambdaExpression();

    public void WriteEndConstructor() => this.EmitEndConstructor();

    public void WriteEndLambdaDelegate() => this.EmitEndLambdaDelegate();

    public virtual void WriteLineContinuation()
    {
    }

    public virtual void WriteBooleanLiteral(bool value) => this.WriteSnippet(value.ToString((IFormatProvider) CultureInfo.InvariantCulture));

    public void Dispose()
    {
      this.Dispose(true);
      GC.SuppressFinalize((object) this);
    }

    public void Clear()
    {
      if (this.InnerWriter == null)
        return;
      this.InnerWriter.GetStringBuilder().Clear();
    }

    public CodeSnippetStatement ToStatement() => new CodeSnippetStatement(this.Content);

    public CodeSnippetTypeMember ToTypeMember() => new CodeSnippetTypeMember(this.Content);

    protected internal abstract void EmitStartLambdaDelegate(string[] parameterNames);

    protected internal abstract void EmitStartLambdaExpression(string[] parameterNames);

    protected internal abstract void EmitStartConstructor(string typeName);

    protected internal abstract void EmitStartMethodInvoke(string methodName);

    protected internal virtual void EmitStartMethodInvoke(
      string methodName,
      params string[] genericArguments)
    {
      this.EmitStartMethodInvoke(methodName);
    }

    protected internal abstract void EmitEndLambdaDelegate();

    protected internal abstract void EmitEndLambdaExpression();

    protected internal abstract void EmitEndConstructor();

    protected internal abstract void EmitEndMethodInvoke();

    protected virtual void Dispose(bool disposing)
    {
      if (!disposing || this._writer == null)
        return;
      this._writer.Dispose();
    }

    private enum WriterMode
    {
      Constructor,
      MethodCall,
      LambdaDelegate,
      LambdaExpression,
    }
  }
}
